<?php

/**
 * This is the model class for table "{{products}}".
 *
 * The followings are the available columns in table '{{products}}':
 * @property string $ID
 * @property integer $CategoryId
 * @property string $ENName
 * @property string $ZHName
 * @property string $ENSummary
 * @property string $ZHSummary
 * @property string $ENContent
 * @property string $ZHContent
 * @property string $Pic1
 * @property string $Pic2
 * @property string $Pic3
 * @property string $Pic4
 * @property string $Pic5
 * @property integer $IndexFlag
 * @property integer $OptAdminID
 * @property string $OptTime
 * @property integer $Sorts
 */
class Products extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Products the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{products}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('CategoryId, ENName, ZHName', 'required'),
			array('CategoryId, IndexFlag, OptAdminID, Sorts', 'numerical', 'integerOnly'=>true),
			array('ENName, ZHName', 'length', 'max'=>100),
			array('ENSummary, ZHSummary, Pic1, Pic2, Pic3, Pic4, Pic5', 'length', 'max'=>255),
			array('ZHContent', 'safe'),
			array('ENContent', 'safe'),			
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID, CategoryId, ENName, ZHName, ENSummary, ZHSummary, ENContent, ZHContent, Pic1, Pic2, Pic3, Pic4, Pic5, IndexFlag, OptAdminID, OptTime, Sorts', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'CategoryId' => 'Category',
			'ENName' => 'Enname',
			'ZHName' => 'Zhname',
			'ENSummary' => 'Ensummary',
			'ZHSummary' => 'Zhsummary',
			'ENContent' => 'Encontent',
			'ZHContent' => 'Zhcontent',
			'Pic1' => 'Pic1',
			'Pic2' => 'Pic2',
			'Pic3' => 'Pic3',
			'Pic4' => 'Pic4',
			'Pic5' => 'Pic5',
			'IndexFlag' => 'Index Flag',
			'OptAdminID' => 'Opt Admin',
			'OptTime' => 'Opt Time',
			'Sorts' => 'sorts',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID,true);
		$criteria->compare('CategoryId',$this->CategoryId);
		$criteria->compare('ENName',$this->ENName,true);
		$criteria->compare('ZHName',$this->ZHName,true);
		$criteria->compare('ENSummary',$this->ENSummary,true);
		$criteria->compare('ZHSummary',$this->ZHSummary,true);
		$criteria->compare('ENContent',$this->ENContent,true);
		$criteria->compare('ZHContent',$this->ZHContent,true);
		$criteria->compare('Pic1',$this->Pic1,true);
		$criteria->compare('Pic2',$this->Pic2,true);
		$criteria->compare('Pic3',$this->Pic3,true);
		$criteria->compare('Pic4',$this->Pic4,true);
		$criteria->compare('Pic5',$this->Pic5,true);
		$criteria->compare('IndexFlag',$this->IndexFlag);
		$criteria->compare('OptAdminID',$this->OptAdminID);
		$criteria->compare('OptTime',$this->OptTime,true);
		$criteria->compare('Sorts',$this->Sorts);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}